package com.xingzhe.pengji.security.controller.common;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.danga.MemCached.MemCachedClient;

/**
 * @Title ： 三江学院 毕业设计
 * @Description ：
 * @author ：LuFengLiang
 * @Company: IT行者工作室
 * @Copyright: Copyright (c) 2012-2-24
 * @version ： 1.0
 */
@Controller
@RequestMapping("/login")
public class JsonController
{

    private Logger logger = LoggerFactory.getLogger(JsonController.class);

    @Autowired
    private MemCachedClient memCachedClient;

    @SuppressWarnings("unchecked")
    @ResponseBody
    // @Secured("ADMIN_ROLE")
    @RequestMapping("/1.html")
    public Object login()
    {
        List<List<Integer>> list;
        list = (List<List<Integer>>) memCachedClient.get("list");
        if (null != list && 0 != list.size())
        {
            logger.debug("缓存！");
            return list;
        }
        else
        {
            list = new ArrayList<List<Integer>>();
            List<Integer> l=null;
            for (int i = 0; i < 100; i++)
            {
               // list.add(i);
                l=new ArrayList<Integer>();
                for (int j = 0; j < 1000; j++)
                {
                    l.add(j);
                }
                list.add(l);
            }
            memCachedClient.add("list", list);
            logger.debug("重新加载！");
            return list;
        }
    }

    @ResponseBody
    @RequestMapping(value = "/2.html")
    /**不需要做请求头的设置否者会出现乱码的问题*/
    // , headers = "Accept=application/json,Accept-Charset=utf-8"
    public Object loginUser()
    {
        return "xs";
    }
}
